<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Http\Controllers;

use App\Format\CoverConfigFormat;
use App\Services\CoverConfigService;
use Illuminate\Http\Request;

class CoverConfigController extends Controller
{
    protected $coverConfigService;

    public function __construct(CoverConfigService $coverConfigService)
    {
        $this->coverConfigService = $coverConfigService;
    }

    public function getList(Request $request)
    {
        $search = [];
        if ($request->input('name')) {
            $search['name'] = $request->input('name');
        }

        $res = $this->coverConfigService->getList($search);

        return renderSuccessJson($res);
    }

    public function update(Request $request)
    {
        $format = new CoverConfigFormat($request->all());
        $this->coverConfigService->update($format);
        return renderSuccessJson();
    }
}
